#ifndef _DS_SQ_LIST_H
#define _DS_SQ_LIST_H

#include "../ds_types.h"
#include <stdlib.h>

#define SQ_INIT_SIZE 20
#define SQ_INCREMENT 10

/* 
 * Sequential storage list 
 * Unlike Array, it's space grows dynamically
 */

extern Status sqlist_init(sq_list *sl, size_t struct_size);

static inline Status sqlist_destroy(sq_list *sl)
{
	free(sl->data);
	sl->length = 0;
	sl->size = 0;
}

static inline Status sqlist_clear(sq_list *sl)
{
	sl->length = 0;
}

static inline Bool sqlist_empty(const sq_list *sl)
{
	return !(sl->length);
}

static inline size_t sqlist_length(const sq_list *sl)
{
	return sl->length;
}

extern void *sqlist_getelem(const sq_list *sl, size_t i, size_t struct_size);

extern size_t sqlist_locateelem(const sq_list *sl, const void *e, 
		int cmp(const void *e1, const void *e2), 
		size_t struct_size);

extern Status sqlist_insert(sq_list *sl, size_t i, const void *e, 
		size_t struct_size);

extern Status sqlist_delete(sq_list *sl, size_t i, void *e, 
		size_t struct_size);
extern void sqlist_traverse(const sq_list *sl, 
		Bool visit(const void *),
		size_t struct_size);
void sqlist_merge(const sq_list* s1,const sq_list* s2, sq_list *s3,
		int compare(const void *,const void *), size_t struct_size);

#endif
